from django.shortcuts import render
from django.views import View


from goods.models import GoodsCategory, GoodsChannel, GoodsChannelGroup
from contents.models import ContentCategory, Content
from contents.utils import get_categories


# Create your views here.
class IndexView(View):
    def get(self, request):
        categories = get_categories()
        contents = {}
        content_categories = ContentCategory.objects.all()
        for content_category in content_categories:
            contents[content_category.key] = content_category.content_set.filter(status=True).order_by('sequence')

        context = {
            'categories': categories,
            'contents': contents
            }

        return render(request, 'index.html', context)
